ui/cocoa.m: Add Reset and Power Down menu items to Machine menu
PATCH 3/3 ui/cocoa.m: Add Reset and Power Down menu items to Machine menu
Adds Reset and Power Down menu items to the Machine menu.
--- ui/cocoa.m | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-)
ui/cocoa.m +24 -0
@@ -828,6 +828,8 @@ QemuCocoaView *cocoaView; - (void)removePause; - (void)ejectDeviceMedia:(id)sender; - (void)changeDeviceMedia:(id)sender; +- (void)restartQemu:(id)sender; +- (void)powerDown:(id)sender; @end @implementation QemuCocoaAppController
@@ -1064,6 +1066,18 @@ QemuCocoaView *cocoaView; } } +/* Restarts QEMU */ +- (void)restartQemu:(id)sender +{ + qemu_system_reset_request(); +} + +/* Powers down the emulator */ +- (void)powerDown:(id)sender +{ + qmp_system_powerdown(NULL); +} + @end
@@ -1202,6 +1216,15 @@ static void addDeviceMenuItems(NSMenu * menu) } } +// Adds the Reset and Power Down menu items to the specifed menu +static void addResetPowerDownMenuItems(NSMenu* menu) +{ + [menu addItem: [NSMenuItem separatorItem]]; + [menu addItem: [[[NSMenuItem alloc] initWithTitle: @"Reset" action: @selector(restartQemu:) keyEquivalent: @""] autorelease]]; + [menu addItem: [[[NSMenuItem alloc] initWithTitle: @"Power Down" action: @selector(powerDown:) keyEquivalent: @""] autorelease]]; +} + + /* Adds the Machine menu to the menu bar. Has to be added separately because QEMU needs
@@ -1222,6 +1245,7 @@ static void createMachineMenu() [[NSApp mainMenu] insertItem: menuItem atIndex: 2]; // Insert after View menu [[menu itemWithTitle: @"Resume"] setEnabled: NO]; // Disables the Resume menu item because it isn't needed right now. addDeviceMenuItems(menu); + addResetPowerDownMenuItems(menu); } #pragma mark qemu
Signature · 1 line
1.7.5.4
Quoted 3 lines · Programmingkid
Adds Reset and Power Down menu items to the Machine menu.
Signed-off-by John Arbuckle <[email protected]>
This patch mostly looks good and pretty straightforward. If you put it as #2 in this series then we can get it into master even if we need to have another review-go-around about the device eject/mediachange code.
Quoted 10 lines
--- ui/cocoa.m | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-)ui/cocoa.m +0
-0
ui/cocoa.m QemuCocoaView *cocoaView; · line 831
Quoted 4 lines
ui/cocoa.m +1
-0@@ -828,6 +828,8 @@ QemuCocoaView *cocoaView; - (void)removePause; - (void)ejectDeviceMedia:(id)sender; - (void)changeDeviceMedia:(id)sender; +- (void)restartQemu:(id)sender;
"QEMU"
ui/cocoa.m QemuCocoaView *cocoaView; · line 832
Quoted 1 line
ui/cocoa.m +1
-0+- (void)powerDown:(id)sender;
Why doesn't this method name have "QEMU" in it?
Quoted 12 lines
ui/cocoa.m +0
-0@end@implementation QemuCocoaAppController
ui/cocoa.m +1
-0@@ -1064,6 +1066,18 @@ QemuCocoaView *cocoaView; } } +/* Restarts QEMU */
ui/cocoa.m QemuCocoaView *cocoaView; · line 1081
Quoted 10 lines
ui/cocoa.m +10
-0+- (void)restartQemu:(id)sender +{ + qemu_system_reset_request(); +} + +/* Powers down the emulator */ +- (void)powerDown:(id)sender +{ + qmp_system_powerdown(NULL); +}
This is inconsistent -- we should use qmp_system_reset(NULL), which is then doing the same as the GTK UI and means we're using QMP functions for both reset and powerdown.
Quoted 8 lines
ui/cocoa.m +1
-0+ @end
ui/cocoa.m static void addDeviceMenuItems(NSMenu * menu) · line 1221
Quoted 6 lines
ui/cocoa.m +1
-0@@ -1202,6 +1216,15 @@ static void addDeviceMenuItems(NSMenu * menu) } } +// Adds the Reset and Power Down menu items to the specifed menu
"specified"
Quoted 18 lines
ui/cocoa.m +5
-0+static void addResetPowerDownMenuItems(NSMenu* menu) +{ + [menu addItem: [NSMenuItem separatorItem]]; + [menu addItem: [[[NSMenuItem alloc] initWithTitle: @"Reset" action: @selector(restartQemu:) keyEquivalent: @""] autorelease]]; + [menu addItem: [[[NSMenuItem alloc] initWithTitle: @"Power Down"action: @selector(powerDown:) keyEquivalent: @""] autorelease]];
ui/cocoa.m +3
-0+} + + /* Adds the Machine menu to the menu bar. Has to be added separately because QEMU needs@@ -1222,6 +1245,7 @@ static void createMachineMenu() [[NSApp mainMenu] insertItem: menuItem atIndex: 2]; // Insert afterView menu
[[menu itemWithTitle: @"Resume"] setEnabled: NO]; // Disables the
Resume menu item because it isn't needed right now.
Quoted 3 lines
addDeviceMenuItems(menu);+ addResetPowerDownMenuItems(menu);
}
thanks
-- PMM